<?phpsession_start();
include('database.php');$conn=$_SESSION[conn];if(isset($_POST[per_page])){$_SESSION[per_page]=$_POST[per_page];$perpage = $_POST[per_page];}else{$perpage = $_SESSION[per_page];}
/*
Template Name: Template Search Business Partner
*/

	get_header();

	if (have_posts()) : while (have_posts()) : the_post(); 

	// GET CUSTOM SIDEBAR
	$sidebar = get_post_meta($post->ID, 'sidebar_value', true);
//if you already login as entrepreneur, then u can use this featureif(isset($_SESSION[login]) and $_SESSION[user_type]=='entrepreneur'){
	?><head><link rel='stylesheet' type='text/css' href='<?php echo bloginfo('template_url') ?>/dashboard.css' /><link rel="stylesheet" type="text/css" href="<?php echo bloginfo('template_url') ?>/main_dashboard.css"/></head>	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script><script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript" src="<?php echo bloginfo('template_url') ?>/js/script.js"></script><br><br>    <div id="dolphincontainer">    <div id="dolphinnav">    <ul>    <li><a href="<?php echo bloginfo('url')?>/entrepreneur_dashboard/" title="" ><span>Dashboard</span></a></li>    <li><a href="<?php echo bloginfo('url')?>/add_proposal/" title="" ><span>Add Proposal</span></a></li>	<li><a href="<?php echo bloginfo('url')?>/search_investor/" title="" ><span>Search Investor</span></a></li>	<li><a href="<?php echo bloginfo('url')?>/search_partner/" title="" class="current"><span>Search Partner</span></a></li>    <li><a href="<?php echo bloginfo('url')?>/edit-profile/" title=""><span>Profile</span></a></li>	<li><a href="<?php echo bloginfo('url')?>/upgrade_plan/" title="" ><span><font color=red>Upgrade Plan Now</font></span></a></li>	<li><a href="<?php echo bloginfo('url')?>/buy_nudge/" title="" ><span><font color=red>Buy Nudge</font></span></a></li>       </ul>    </div>    </div>

	<div id="content">

		<div class="contentbox <?php
			if ($sidebar == 'No sidebar') :

				echo'wfull';

			elseif ($sidebar == 'Buddy Sidebar') :

				echo'w720';

			else :

				echo'w620';

			endif; ?>"><?php	//pagingif(isset($_GET["hal"])){	$page = intval($_GET["hal"]);}else {$page = 1;}$calc = $perpage * $page;$start = $calc - $perpage;	?><table rules="none" style="border:0px;border:none;width:100%;text-align:center">		<form action="" method="POST" name="form_search" id="form_search" >		<tbody id="entrepreneur_search_engine" style="">				<tr bgcolor=silver>								<td style="border:none" width="20%">					Select Country:				</td>								<td style="border:none" width="20%">					Select State:				</td>				<td style="border:none" width="20%">					Select Industry:				</td>								<td style="border:none" width="20%">					Area of Expertise:				</td>								<td style="border:none">								</td>		</tr>		<tr bgcolor=silver><script type="text/javascript">$(document).ready(function() {    	$("#business_partner_country").change(function() {		$(this).after('<div id="loader"><img src="<?php echo bloginfo('template_url'); ?>/images/loading.gif" alt="loading State..." /></div>');		$.get('<?php echo bloginfo('template_url'); ?>/country.php?status=entrepreneur&country=' + $(this).val(), function(data) {			$("#business_partner_state").html(data);			$('#loader').slideUp(200, function() {				$(this).remove();			});		});	    });});</script>								<td style="border:none" width="20%">							<select id="business_partner_country" name="business_partner_country" style="width:150px; height:25px; font-size:15px">							<option value="">Select One</option>							<?php							$q_get_country= "select distinct country_name,country_id from country_entrepreneur";							$hq_get_country= mysql_db_query($DataBase,$q_get_country);														while(list($location,$id) = mysql_fetch_row($hq_get_country))							{							?>							<option value="<?php  echo $location ?>"><?php echo $location ?></option>							<?php							}							?>							</select>				</td>				<td style="border:none" width="20%">							<select id="business_partner_state" name="business_partner_state" style="width:150px; height:25px; font-size:15px"></select>				</td>				<td style="border:none" width="20%">							<select id="business_partner_industry" name="business_partner_industry" style="width:150px; height:25px; font-size:15px">							<option value="">Select One</option>							<option value="Real Estate">Real Estate</option>							<option value="Information Technology">Information Technology</option>							<option value="Food and beverage Industry">Food and beverage Industry</option>							<option value="Tourism Hospitality, Restaurants & Bars">Tourism Hospitality, Restaurants & Bars</option>							<option value="Manufacturing">Manufacturing</option>							<option value="E-Commerce">E-Commerce</option>							<option value="Entertainment">Entertainment</option>							<option value="Pharmacy">Pharmacy</option>							<option value="Personal-care">Personal-care</option>							<option value="Education and Training">Education and Training</option>							<option value="Leisure, Tourism &Hotels">Leisure, Tourism & Hotels</option>							<option value="Transportation">Transportation</option>							<option value="Agriculture">Agriculture</option>							<option value="Building Services & Products">Building Services & Products</option>							<option value="Financial, Business & Legal Services">Financial, Business & Legal Services</option>							<option value="Security & Defense">Security & Defense</option>							<option value="Mining, Oil & Gas">Mining, Oil & Gas</option>							<option value="Retail">Retail</option>							<option value="Marketing & Advertising">Marketing & Advertising</option>							<option value="Fashion & Beauty">Fashion & Beauty</option>							<option value="Aviation">Aviation</option>							<option value="Media & Publishing">Media & Publishing</option>							<option value="Biotechnology& Life Sciences">Biotechnology& Life Sciences</option>							<option value="Telecom & Mobile">Telecom & Mobile</option>							<option value="Others">Others</option>														<!--							<?php							//$q_get_industry= "select distinct industry_1 from proposal";							//$hq_get_industry= mysql_db_query($DataBase,$q_get_industry);							//echo $q_get_data;							//while(list($industry) = mysql_fetch_row($hq_get_industry))							//{														?>							<option value="<?php  //echo $industry ?>"><?php //echo $industry ?></option>							<?php							//}														?>							-->							</select>				</td>								<td style="border:none" width="20%">							<select id="area_of_expertise" name="area_of_expertise" style="width:150px; height:25px; font-size:15px">							<option value="">Select One</option>							<?php							$q_expertise= "select distinct expertise_name from expertise";							$hq_expertise= mysql_db_query($DataBase,$q_expertise);							while(list($expertise) = mysql_fetch_row($hq_expertise))							{														?>							<option value="<?php  echo $expertise ?>"><?php echo $expertise ?></option>							<?php							}														?>							</select>				</td>								<td style="border:none">				<input type="submit" id="search_partner" name="search_partner" value="OK">				</td>						</tr>		</tbody>			</form>		</table>	<form id="view_all" name="view_all" method="POST" action="">	<input type="submit" id="view_all" name="view_all" value="View All" />	</form>	</br>	</br>			<table>	<tr>			<td width="150px" bgcolor=grey>			<Center><b>Image			</td>			<td width="250px" bgcolor=grey>			<Center><b>Brief Profile			</td>			<td width="100px" bgcolor=grey>			<?php if($_GET[industry]=='proposal.industry_1 ASC'){ ?>			<Center><b><a href="<?php echo bloginfo('url')?>/search_partner?industry=proposal.industry_1 DESC" style="color:black;">Industry (DESC)</a>			<?php  }else{  ?>			<Center><b><a href="<?php echo bloginfo('url')?>/search_partner?industry=proposal.industry_1 ASC" style="color:black;">Industry (ASC)</a>			<?php } ?>			</td>			<td width="100px" bgcolor=grey>			<?php if($_GET[expertise]=='proposal.expertise ASC'){ ?>			<Center><b><a href="<?php echo bloginfo('url') ?>/search_partner?expertise=proposal.expertise DESC" style="color:black;">Area of Expertise (DESC)</a>			<?php }else{ ?>			<Center><b><a href="<?php echo bloginfo('url') ?>/search_partner?expertise=proposal.expertise ASC" style="color:black;">Area of Expertise (ASC)</a>			<?php } ?>			</td>			</tr>	</br>	</table>	<?php		if(isset($_POST[business_partner_industry]) and isset($_POST[area_of_expertise]) and $_POST[business_partner_industry]!='' and $_POST[area_of_expertise]!='')	{			//save in the session function			$_SESSION[s_industry]=$_POST[business_partner_industry];			$_SESSION[s_expertise]=$_POST[area_of_expertise];				//search based on the search engine		global pro must come first, and pro and novice				$q_get_proposal= "select proposal.expertise,user.first_name,user.last_name,proposal.total_have_you_raised,proposal.stage,proposal.short_summary,proposal.state,proposal.industry_1,proposal.user_id,proposal.company_name,proposal.management_location,proposal.minimum_investment,proposal.total_raise,proposal.short_summary,proposal.proposal_id from proposal,user where proposal.industry_1='$_SESSION[s_industry]' and proposal.expertise='$_SESSION[s_expertise]' and proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]' ORDER BY user.pakage LIMIT $start,$perpage";			$hq_get_proposal= mysql_db_query($DataBase,$q_get_proposal);			$result = mysqli_query($conn,"select count(*) as Total from proposal,user where proposal.industry_1='$_POST[business_partner_industry]' and proposal.expertise='$_POST[area_of_expertise]' and proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]'");			$rows = mysqli_num_rows($result);			}else if((isset($_GET[industry]) or isset($_GET[expertise])) and ($_SESSION[s_expertise]!='' and $_SESSION[s_industry]!='' )){						$result = mysqli_query($conn,"select count(*) as Total from proposal,user where proposal.industry_1='$_SESSION[s_industry]' and proposal.expertise='$_SESSION[s_expertise]' and proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]'");			$rows = mysqli_num_rows($result);		//this called when they want to short by industry or expertise.			if(isset($_GET[industry]))			{			$q_get_proposal= "select proposal.expertise,user.first_name,user.last_name,proposal.total_have_you_raised,proposal.stage,proposal.short_summary,proposal.state,proposal.industry_1,proposal.user_id,proposal.company_name,proposal.management_location,proposal.minimum_investment,proposal.total_raise,proposal.short_summary,proposal.proposal_id from proposal,user where proposal.industry_1='$_SESSION[s_industry]' and proposal.expertise='$_SESSION[s_expertise]' and proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]' ORDER BY $_GET[industry] LIMIT $start,$perpage";			$hq_get_proposal= mysql_db_query($DataBase,$q_get_proposal);						}			if(isset($_GET[expertise]))			{			$q_get_proposal= "select proposal.expertise,user.first_name,user.last_name,proposal.total_have_you_raised,proposal.stage,proposal.short_summary,proposal.state,proposal.industry_1,proposal.user_id,proposal.company_name,proposal.management_location,proposal.minimum_investment,proposal.total_raise,proposal.short_summary,proposal.proposal_id from proposal,user where proposal.industry_1='$_SESSION[s_industry]' and proposal.expertise='$_SESSION[s_expertise]' and proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]' ORDER BY $_GET[expertise] LIMIT $start,$perpage";			$hq_get_proposal= mysql_db_query($DataBase,$q_get_proposal);						}			}else	{					//clear all session			$_SESSION[s_industry]='';			$_SESSION[s_expertise]='';									//paging			$result = mysqli_query($conn,"select count(*) as Total from proposal,user where proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]'");			$rows = mysqli_num_rows($result);						//view all			if(isset($_GET[industry]))			{			$q_get_proposal= "select proposal.expertise,user.first_name,user.last_name,proposal.total_have_you_raised,proposal.stage,proposal.short_summary,proposal.state,proposal.industry_1,proposal.user_id,proposal.company_name,proposal.management_location,proposal.minimum_investment,proposal.total_raise,proposal.short_summary,proposal.proposal_id from proposal,user where proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]' ORDER BY $_GET[industry] LIMIT $start,$perpage";			$hq_get_proposal= mysql_db_query($DataBase,$q_get_proposal);						}else if(isset($_GET[expertise])){			$q_get_proposal= "select proposal.expertise,user.first_name,user.last_name,proposal.total_have_you_raised,proposal.stage,proposal.short_summary,proposal.state,proposal.industry_1,proposal.user_id,proposal.company_name,proposal.management_location,proposal.minimum_investment,proposal.total_raise,proposal.short_summary,proposal.proposal_id from proposal,user where proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]' ORDER BY $_GET[expertise] LIMIT $start,$perpage";			$hq_get_proposal= mysql_db_query($DataBase,$q_get_proposal);									}else			{			$q_get_proposal= "select proposal.expertise,user.first_name,user.last_name,proposal.total_have_you_raised,proposal.stage,proposal.short_summary,proposal.state,proposal.industry_1,proposal.user_id,proposal.company_name,proposal.management_location,proposal.minimum_investment,proposal.total_raise,proposal.short_summary,proposal.proposal_id from proposal,user where proposal.status='active' and user.user_id=proposal.user_id and user.user_id!='$_SESSION[user_id]' ORDER BY user.pakage ASC LIMIT $start,$perpage";			$hq_get_proposal= mysql_db_query($DataBase,$q_get_proposal);						}			 	}			//echo $q_get_data;			while(list($expertise,$first_name,$last_name,$total_have_you_raised,$stage,$summary,$state,$industry,$user_id,$company_name,$management_location,$minimum_investment,$total_raise,$short_summary,$proposal_id) = mysql_fetch_row($hq_get_proposal))			{									$q_get_image= "select image from user where user_id='$user_id'";			$hq_get_image= mysql_db_query($DataBase,$q_get_image);			//echo $q_get_data;			while(list($image) = mysql_fetch_row($hq_get_image))			{										?>			<table border=1 bgcolor=gray >			<tr>			<td width="150px" bgcolor=silver>						<center>									<a href="#">					<?php if($image==''){  ?>					<img src="<?php echo bloginfo('template_url')?>/images/no_image.gif" width="150" height="150" />					<?php }else{ ?>					<img src="data:image/jpeg;base64,<?php echo base64_encode($image); ?>" width="150" height="150" />					<?php }  ?>										</a>							</td>			<td bgcolor=silver width="250px" >															Entreperneur ID: <b><?php echo $user_id ?></b></br>					</br>					Name: <b><?php echo $first_name." ".$last_name; ?></b></br>					Country: <b><?php echo $management_location ?></b></br>					State: <b><?php echo $state ?></b></br>					Summary : <b><?php echo $short_summary; ?></b>					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;					<?php			$q_cek= "select count(*),status from nudge where investor_id='$_SESSION[user_id]' and proposal_id='$proposal_id'";			$hq_cek= mysql_db_query($DataBase,$q_cek);						while(list($nudge_id,$status) = mysql_fetch_row($hq_cek))			{			$nudge=$nudge_id;						?>						</td>			<td width="100px" bgcolor=silver>			<?php  echo $industry; ?>			</td>			<td width="100px" bgcolor=silver>			<b><font><?php echo $expertise; ?></font></b>			</td>						</tr>			<tr>			<!-- if the nudge has been approved by entrepreneur... -->						<td bgcolor=black colspan=4><a href="<?php echo bloginfo('template_url') ?>/view_proposal.php?proposal_id=<?php echo $proposal_id ?>" ><b>Find Out More --></b></a>				</td>									</tr>						</br>			<?php						}			?>			</table>			<?php } } 			$error = mysql_num_rows($hq_get_proposal);			if($error==0)			{			echo "Data Not Found.";			}			?>			</br></br>			<div style="text-align:right;">									<?php//pagingif(isset($page)){if($rows){$rs = mysqli_fetch_assoc($result);$total = $rs["Total"];}$totalPages = ceil($total / $perpage);if($page <=1 ){echo "<span id='page_links' style='font-weight: bold;'></span>";}else{$j = $page - 1;?><span><a id='page_a_link' href='<?php echo bloginfo('url') ?>/search_partner?hal=<?php echo $j; ?>'><img src="<?php echo bloginfo('template_url') ?>/images/back.jpg"></img></a></span><?php}for($i=1; $i <= $totalPages; $i++){if($i<>$page){?><span><a id='page_a_link' href='<?php echo bloginfo('url') ?>/search_partner?hal=<?php echo $i ?>'><?php echo $i ?></a></span><?php}else{echo "<span id='page_links' style='font-weight: bold;'></span>";}}if($page == $totalPages  or $totalPages==0) //if the page is only 1{echo "<span id='page_links' style='font-weight: bold;'></span>";}else{$j = $page + 1;?><span><a id='page_a_link' href='<?php echo bloginfo('url') ?>/search_partner?hal=<?php echo $j ?>'><img src="<?php echo bloginfo('template_url') ?>/images/next.jpg"></img></a></span><?php}}?>			</div> <div align=right><form id="form_per_page" name="form_per_page" method="POST" action="<?php echo bloginfo('url') ?>/search_partner/">Results per page<select id="per_page" name="per_page" style="width:60px; height:25px; font-size:15px" onchange="document.forms['form_per_page'].submit();"><option value="5" <?php if($_SESSION[per_page]==5){ echo"selected"; } ?> >5</option><option value="10" <?php if($_SESSION[per_page]==10){ echo"selected"; } ?> >10</option><option value="15" <?php if($_SESSION[per_page]==15){ echo"selected"; } ?> >15</option><option value="20" <?php if($_SESSION[per_page]==20){ echo"selected"; } ?> >20</option></select></form></div>			<?php  }else{if(!isset($_SESSION[login])){?>Please <a href="<?php echo bloginfo('url') ?>/login-page/">Login</a> / <a href="<?php echo bloginfo('url') ?>/register-user/">Register</a> first<?php}else{?>This feature is only for Entrepreneur users.<?php}}?>						
			<?php																																				
				// CONTENT
				//the_content();

				echo '<div class="clear h20"><!-- --></div>';
				
				// PAGINATION
				wp_link_pages(array('before' => '<p><strong>'.__( 'Pages','pandathemes' ).':</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));
				
				// COMMENTS ETC.
				if ( $theme_options['pages_metas'] == 'enable' ) : comments_template(); endif;

	endwhile;

		else : echo '<div class="contentbox w620"><h2>404</h2><p>'.__('Sorry, no posts matched your criteria.','pandathemes').'</p>';

	endif; ?>

	</div> <!-- end_of_contentbox -->

		<?php
			// SIDEBAR
			if ($sidebar == 'Buddy Sidebar') :
				include(TEMPLATEPATH.'/inc/sidebar_buddy.php');
			else :
				include(TEMPLATEPATH.'/inc/sidebar.php');
			endif;

	get_footer();

?>